<?php
/**
 * Created by PhpStorm.
 * User: hlcc
 * Date: 2016/12/25
 * Time: 10:47
 */
// curl demo

//get

// 创建一个cURL资源
/*$ch = curl_init();
$url = 'www.baidu.com';
$mobile = '18817555623';
$msg = mt_rand(1000,9999);
$url = "http://www.midoodoo.cn/index.php/sendyun001/index?user=tele001&passwd=123456&singned=抖抖&mobile=$mobile&msg=$msg";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt ( $ch, CURLOPT_HEADER, 0 );
//curl_setopt($ch, CURLOPT_HEADER, 0);
$res = curl_exec($ch);
var_dump($msg);
var_dump(curl_errno($ch));
var_dump($res);
curl_close($ch);*/


//POST
$curl = curl_init();
$url =  "http://106.ihuyi.cn/webservice/sms.php?method=Submit";
$mobile = '18817555623';

$mobile_code = mt_rand(1000,9000);
//session('htw_curl_code',$mobile_code,30);
$curlPost = "account=cf_xinzhizun&password=1234567&mobile=".$mobile."&content=".rawurlencode("您的验证码是：".$mobile_code."。请不要把验证码泄露给其他人。");
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_NOBODY, true);
curl_setopt($curl, CURLOPT_POST, true); //POST 请求
curl_setopt($curl, CURLOPT_POSTFIELDS, $curlPost);

$return_str = curl_exec($curl);
curl_close($curl);
var_dump($return_str) ;

